//
//(C) Copyright 2011 HongKong Airline.,Ltd. 
//
/**
 * messageAction
 * 项目名称:代购系统
 * @author Mengxiangliang
 * 功能描述:
 * 历史版本:2013-01-04 v1.0.0 Mengxiangliang  创建:
 * @version [V1] 
 */
package com.gamutsoft.amb.message.action;

import java.util.List;
import java.util.Map;

import com.gamutsoft.amb.base.action.BaseAction;
import com.gamutsoft.amb.common.bean.QueryExample;
import com.gamutsoft.amb.common.constants.Constants;
import com.gamutsoft.amb.common.exception.BusinessException;
import com.gamutsoft.amb.common.util.ConditionUtil;
import com.gamutsoft.amb.common.util.PageUtil;
import com.gamutsoft.amb.message.model.Message;
import com.gamutsoft.amb.message.service.IMessageService;
import com.gamutsoft.amb.messageuser.model.MessageUser;


@SuppressWarnings({"serial","rawtypes"})
public class MessageAction extends BaseAction {
	
	private Message message;
	
	private List<Map> messageList;
	
	private IMessageService messageService;
	
	private MessageUser messageUser;
	
	private Map<String,List<Map>> messageMap;
	
	private PageUtil pageUtil;

	/**
	 * 初始化查询Message信息
	 * @author Mengxiangliang
	 * @return
	 */
	public String searchMessageHasRead()throws BusinessException, Exception {
		try {
		    QueryExample qe =ConditionUtil.copyConditionBySql(this.getRequest());
		    pageUtil =new PageUtil(this.getRequest());
		    pageUtil.setPageSize(PageUtil.PAGESIZE);
			qe.setPageUtil(pageUtil);
			if(messageUser==null){
				messageUser=new MessageUser();
				messageUser.setUserId(super.getSystemUser().getId());
				messageUser.setStatus(Constants.MESSAGE_READ_STATUS_ON);
			}
			messageList = messageService.searchMessageByWhere(qe, messageUser);
		}catch(Exception e){
			log.error(e);
			throw e;
		}
		return "init_search_message_success";
	}
	/**
	 * 初始化查询Message信息
	 * @author Mengxiangliang
	 * @return
	 */
	public String searchMessageNoRead()throws BusinessException, Exception {
		try {
		    QueryExample qe =ConditionUtil.copyConditionBySql(this.getRequest());
		    pageUtil =new PageUtil(this.getRequest());
		    pageUtil.setPageSize(PageUtil.PAGESIZE);
			qe.setPageUtil(pageUtil);
			if(messageUser==null){
				messageUser=new MessageUser();
				messageUser.setUserId(super.getSystemUser().getId());
				messageUser.setStatus(Constants.MESSAGE_READ_STATUS_OFF);
			}
			messageList = messageService.searchMessageByWhere(qe, messageUser);
		}catch(Exception e){
			log.error(e);
			throw e;
		}
		return "init_search_message_success";
	}

	public Map<String, List<Map>> getMessageMap() {
		return messageMap;
	}
	public void setMessageMap(Map<String, List<Map>> messageMap) {
		this.messageMap = messageMap;
	}
	public PageUtil getPageUtil() {
		return pageUtil;
	}
	public void setPageUtil(PageUtil pageUtil) {
		this.pageUtil = pageUtil;
	}
	/**
	 * @return the message
	 */
	public Message getMessage() {
		return message;
	}

	/**
	 * @param message the message to set
	 */
	public void setMessage(Message message) {
		this.message = message;
	}

	/**
	 * @return the messageList
	 */
	public List<Map> getMessageList() {
		return messageList;
	}

	/**
	 * @param messageList the messageList to set
	 */
	public void setMessageList(List<Map> messageList) {
		this.messageList = messageList;
	}

	/**
	 * @param messageService the messageService to set
	 */
	public void setMessageService(IMessageService messageService) {
		this.messageService = messageService;
	}



	public MessageUser getMessageUser() {
		return messageUser;
	}



	public void setMessageUser(MessageUser messageUser) {
		this.messageUser = messageUser;
	}
	
}
